]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
dateMenu: Add "Open Clocks" entry
authorMathieu Bridon <bochecha@fedoraproject.org>
Sat, 15 Dec 2012 10:30:03 +0000 (11:30 +0100)
committerZeeshan Ali (Khattak) <zeeshanak@gnome.org>
Wed, 16 Jan 2013 03:06:55 +0000 (05:06 +0200)
This is similar to how the dateMenu already allows opening the calendar
application. However, the new entry only appears if GNOME Clocks is
installed, as it is not a core GNOME application.

https://bugzilla.gnome.org/show_bug.cgi?id=644390

js/ui/dateMenu.js

index 7d027da2cc9795c3974fbbd26ea569648603e528..430ebfbc8d04be04223205477b11956b0cda7492 100644 (file)
@@ -93,6 +93,15 @@ const DateMenuButton = new Lang.Class({
         this._openCalendarItem.actor.can_focus = false;
         vbox.add(this._openCalendarItem.actor, {y_align: St.Align.END, expand: true, y_fill: false});
 
+        this._openClocksItem = new PopupMenu.PopupMenuItem(_("Open Clocks"));
+        this._openClocksItem.connect('activate', Lang.bind(this, this._onOpenClocksActivate));
+        this._openClocksItem.actor.can_focus = false;
+        vbox.add(this._openClocksItem.actor, {y_align: St.Align.END, expand: true, y_fill: false});
+
+        Shell.AppSystem.get_default().connect('installed-changed',
+                                              Lang.bind(this, this._appInstalledChanged));
+        this._appInstalledChanged();
+
         item = this.menu.addSettingsAction(_("Date and Time Settings"), 'gnome-datetime-panel.desktop');
         if (item) {
             item.actor.show_on_set_parent = false;
@@ -147,6 +156,11 @@ const DateMenuButton = new Lang.Class({
         this._sessionUpdated();
     },
 
+    _appInstalledChanged: function() {
+        let app = Shell.AppSystem.get_default().lookup_app('gnome-clocks.desktop');
+        this._openClocksItem.actor.visible = app !== null;
+    },
+
     _setEventsVisibility: function(visible) {
         this._openCalendarItem.actor.visible = visible;
         this._separator.visible = visible;
@@ -198,5 +212,11 @@ const DateMenuButton = new Lang.Class({
 
         let app = Gio.AppInfo.get_default_for_type('text/calendar', false);
         app.launch([], global.create_app_launch_context());
+    },
+
+    _onOpenClocksActivate: function() {
+        this.menu.close();
+        let app = Shell.AppSystem.get_default().lookup_app('gnome-clocks.desktop');
+        app.activate();
     }
 });